import request from '@/utils/request'

/**
 * 根据三级Id分页获取spu列表
 * @returns getCategory1List
 */
export function getSpuListApi({page,limit,category3Id}) {
  return request({
    url: `/admin/product/${page}/${limit}`,
    method: 'get',
    params:{
      category3Id,
    }
  })
}

/**
 * 获取销售属性列表
 * @returns 
 */
export function baseSaleAttrListApi() {
  return request({
    url: `/admin/product/baseSaleAttrList`,
    method: 'get'
  })
}

/*
{
  "category3Id": 0,
  "description": "string",
  "id": 0,
  "spuImageList": [
    {
      "id": 0,
      "imgName": "string",
      "imgUrl": "string",
      "spuId": 0
    }
  ],
  "spuName": "string",
  "spuSaleAttrList": [
    {
      "baseSaleAttrId": 0,
      "id": 0,
      "saleAttrName": "string",
      "spuId": 0,
      "spuSaleAttrValueList": [
        {
          "baseSaleAttrId": 0,
          "id": 0,
          "isChecked": "string",
          "saleAttrName": "string",
          "saleAttrValueName": "string",
          "spuId": 0
        }
      ]
    }
  ],
  "tmId": 0
}
*/
/**
 * 添加Spu
 */
export function addSpuInfoApi(data) {
  return request({
    url: `/admin/product/saveSpuInfo`,
    method: 'post',
    data
  })
}

/**
 * 删除spu
 * @param {*} spuId 
 * @returns 
 */
export function removeSpuInfoApi(spuId) {
  return request({
    url: `/admin/product/deleteSpu/${spuId}`,
    method: 'delete'
  })
}

/**
 * 获取spu图片列表
 * @param {*} spuId 
 * @returns 
 */
export function getSpuImageListApi(spuId) {
  return request({
    url: `/admin/product/spuImageList/${spuId}`,
    method: 'get'
  })
}


/**
 * 获取spu属性列表
 * @param {*} spuId 
 * @returns 
 */
export function getSpuSaleAttrListApi(spuId) {
  return request({
    url: `/admin/product/spuSaleAttrList/${spuId}`,
    method: 'get'
  })
}

/**
 * 修改spu
 * @param {*} data 
 * @returns 
 */
export function updateSpuInfoApi(data) {
  return request({
    url: `/admin/product/updateSpuInfo`,
    method: 'post',
    data
  })
}